-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added sockHost, changed how sock URL is built #1858
Conversation
client-src/default/index.js
Outdated
let sockHost = hostname; | ||
let sockPath = '/sockjs-node'; | ||
let sockPort = urlParts.port; | ||
if (urlParts.path != null && urlParts.path !== '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use strict equality operator. Or are you intentionally doing so to include undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how it was here: https://github.com/webpack/webpack-dev-server/blob/master/client-src/default/index.js#L235. I kept it that way under the assumption that it might need to catch undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I didn't know that it was already used...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Loonride i think we should fix using != (
==` and etc) in our code base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evilebottnawi should I fix it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to change !==
, but its change is the breaking change, so please rewrite as below.
if ((urlParts.path !== null || urlParts.path !== undefined) && urlParts.path !== '/') {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think urlParts.path != null
would turn into (urlParts.path !== null && urlParts.path !== undefined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. My mistake.
lib/options.json
Outdated
"type": "string" | ||
}, | ||
{ | ||
"type": "null" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't have to write explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the "type": "null"
? The host
option has the same format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we discussed here, and I also don't think it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good job, one note above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
For Bugs and Features; did you add new tests?
Yes
Motivation / Use-Case
As mentioned here: #1777, there could potentially be a need for a
sockHost
which is different from thehost
option.I also realized that when
sockPort
was added, a problem could occur ifsockPort
was included butsockPath
was not. Specifically, they both checkurlParts.path === '/'
to see if the query string should be parsed or not, but that method of checking only works if a single option is passed in throughurlParts.path
. I can make a minimum reproducible test repo for this problem if needed. This is the reasoning behind partially changing how the sock url is built.Breaking Changes
None
Additional Info